home *** CD-ROM | disk | FTP | other *** search
/ Game Classics 1 / Game Classics 1.iso / wingames / vegas / wcdbrk2.c < prev    next >
C/C++ Source or Header  |  1992-09-01  |  17KB  |  681 lines

  1. /*********************************************************************
  2.     PROGRAM: WCDBRK2.C
  3.  
  4.     PURPOSE: Code Break game
  5.  
  6.     AUTHOR:  Ken Fogel
  7.          Omnibus Systems
  8.          8108 Norfolk Road
  9.          Cote St-Luc, Québec
  10.          Canada   H4X 1A3
  11.          (514) 487-1565
  12.          CompuServe: 74646,2157
  13.  
  14.     REVISION: April 22, 1992 - Version 2.1
  15.                               Corrected a bug when multiple blue
  16.                                  pegs are in the secret code
  17.  
  18.              June 1, 1991 - Version 2
  19.                                      Full Colour/Bitmaps
  20.  
  21.                  April 22, 1991 - Version 1.01
  22.                  April 15, 1991 - Version 1
  23.  
  24. *********************************************************************/
  25.  
  26. #include <windows.h>           /* required for all Windows applications */
  27. #include <stdlib.h>
  28. #include <stdio.h>
  29. #include <string.h>
  30. #include <time.h>
  31. #include "wcdbrk2.h"        /* specific to this program */
  32.  
  33. HANDLE  hInst;                  /* current instance */
  34. HWND      hGameGrid[10][4];   /* array of buttons */
  35. int      board[10][4];        /* array of guesses */
  36. int      code[4];              /* secret code */
  37. char      clues[10][4];        /* array of clues */
  38. int      cur_round;           /* current row */
  39. int     cur_column;         /* current column */
  40. char      str[80];              /* general purpose string */
  41. HWND    DidIGetItRight;
  42. BOOL    Setup;
  43. BITMAP  Bitmap;
  44. HBITMAP hOldBitmap;
  45. HBITMAP hBoardmap;
  46. HBITMAP hBlclpegmap;
  47. HBITMAP hWhclpegmap;
  48. HBITMAP hPegBoardmap;
  49. LPSTR   lpPegs[8] = {"Bluepeg","Dkpupeg","Grenpeg","Ltblpeg",
  50.                              "Oranpeg","Purppeg","Redpeg","Yellpeg"};
  51. HBITMAP hPegs[8];
  52. int iXpos,iYpos;
  53. int curcolour = 0;
  54. int prevcolour = -1;
  55. int winstate;
  56.  
  57. /*********************************************************************/
  58.  
  59. int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)
  60. HANDLE hInstance;                /* current instance */
  61. HANDLE hPrevInstance;         /* previous instance */
  62. LPSTR lpCmdLine;                /* command line */
  63. int nCmdShow;                    /* show-window type (open/icon) */
  64. {
  65.     MSG msg;                       /* message */
  66.  
  67.     Setup = FALSE;
  68.  
  69.     if (!hPrevInstance)                       /* Other instances of app running? */
  70.         if (!InitApplication(hInstance))      /* Initialize shared things */
  71.             return (FALSE);                   /* Exits if unable to initialize */
  72.  
  73.     /* Perform initializations that apply to a specific instance */
  74.  
  75.     if (!InitInstance(hInstance, nCmdShow))
  76.         return (FALSE);
  77.  
  78.  
  79.     /* Aquire and dispatch messages until a WM_QUIT message is recieved */
  80.  
  81.     while (GetMessage(&msg,                  /* message structure */
  82.                             NULL,     /* handle of window recieving the message */
  83.                             NULL,     /* lowest message to examine */
  84.                             NULL))     /* highest message to examine */
  85.     {
  86.         TranslateMessage(&msg);     /* Translates virtual key codes */
  87.         DispatchMessage(&msg);     /* Dispatches message to window */
  88.     }
  89.     return(msg.wParam);  /* Returns the value from PostQuitMessage */
  90. }
  91.  
  92. /*********************************************************************/
  93.  
  94. BOOL InitApplication(hInstance)
  95. HANDLE hInstance;              /* current instance */
  96. {
  97.     WNDCLASS wc;
  98.  
  99.     /* Fill in window class structure with parameters that describe the */
  100.     /* main window. */
  101.  
  102.     wc.style = CS_DBLCLKS;   /* Class style(s). */
  103.     wc.lpfnWndProc = MainWndProc; /* Function to retrieve messages for */
  104.                                             /* windows of this class */
  105.     wc.cbClsExtra = 0;              /* No per-class extra data */
  106.     wc.cbWndExtra = 0;              /* No per-window extra data */
  107.     wc.hInstance = hInstance;       /* Application that owns the class. */
  108.     wc.hIcon = LoadIcon(hInstance, "Wcdbrk2");
  109.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  110.     wc.hbrBackground = GetStockObject(WHITE_BRUSH);
  111.     wc.lpszMenuName = "WndCdBrkMenu";   /* Name of menu resource in .RC file */
  112.     wc.lpszClassName = "WndCdBrkWClass";/* Name used in call to CreateWindow */
  113.  
  114.     /* Register the window class and return success/failure code */
  115.  
  116.     return (RegisterClass(&wc));
  117.  
  118. }
  119.  
  120. /*********************************************************************/
  121.  
  122. BOOL InitInstance(hInstance, nCmdShow)
  123. HANDLE hInstance;               /* Current instance identifier */
  124. int    nCmdShow;               /* Param for first ShowWindow() call */
  125. {
  126.     HWND hWnd;                   /* Main window handle */
  127.  
  128.     hInst = hInstance;
  129.  
  130.     /* Create a main window for this application instance */
  131.  
  132.     hWnd = CreateWindow(
  133.          "WndCdBrkWClass",         /* See RegisterClass() call */
  134.          "Code Breaker II",      /* Text for window title bar */
  135.          /* The following line creates a window which can be */
  136.          /* minimized to an icon and moved but not re-sized  */
  137.          WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU,
  138.          120,                      /* Initial column */
  139.          30,                       /* Initial row    */
  140.          230,                      /* Width          */
  141.          435,                      /* Height         */
  142.          NULL,                        /* Overlapped windows have no parent */
  143.          NULL,                        /* Use the window class menu */
  144.          hInstance,                    /* This instance owns this window */
  145.          NULL                           /* Pointer not needed */
  146.          );
  147.  
  148.     /* If window could not be created, return "failure" */
  149.  
  150.     if (!hWnd)
  151.         return (FALSE);
  152.  
  153.     /* Make the window visible; update its client area; and return "success" */
  154.  
  155.     ShowWindow(hWnd, nCmdShow);     /* Show the window */
  156.     UpdateWindow(hWnd);               /* Sends WM_PAINT message */
  157.  
  158.     return (TRUE);         /* Returns the value from POSTQUITMESSAGE */
  159.  
  160. }
  161.  
  162. /*********************************************************************/
  163.  
  164. long FAR PASCAL MainWndProc(hWnd, message, wParam, lParam)
  165. HWND hWnd;                      /* window handle */
  166. unsigned message;               /* type of message */
  167. WORD wParam;                   /* additional information */
  168. LONG lParam;                   /* additional information */
  169. {
  170.     FARPROC     lpProcAbout;           /* pointer to the "About" function */
  171.     int x,y;
  172.  
  173.  
  174.     switch (message)
  175.     {
  176.         case WM_CREATE:
  177.             if (!Setup)    /* Do this only once */
  178.             {
  179.                 hBoardmap   = LoadBitmap(hInst,"Board");
  180.                 hPegBoardmap = LoadBitmap(hInst,"Pegboard");
  181.                 hBlclpegmap = LoadBitmap(hInst,"Blclpeg");
  182.                 hWhclpegmap = LoadBitmap(hInst,"Whclpeg");
  183.                 for (x=0;x<8;x++)
  184.                     hPegs[x] = LoadBitmap(hInst,lpPegs[x]);
  185.                 if(!bMakeGameButtons(hWnd))
  186.                 {
  187.                     MessageBox(hWnd,"Failure to create buttons!",NULL,
  188.                                   MB_OK | MB_ICONHAND);
  189.                 }
  190.                 Setup = TRUE;
  191.             }
  192.             vInitialize();
  193.             vMakecode();
  194.             break;
  195.  
  196.         case WM_LBUTTONUP:          /* Mouse button was pressed */
  197.             iXpos = LOWORD(lParam);
  198.             iYpos = HIWORD(lParam);
  199.             if (bCheckPosition(hWnd))
  200.             {
  201.                 board[cur_round][cur_column] = curcolour;
  202.                 vPutPeg(hWnd,curcolour,cur_round,cur_column);
  203.             }
  204.             break;
  205.  
  206.         case WM_PAINT:              /* Time to repaint */
  207.             vBasicScreen(hWnd);
  208.             vMarkColour(hWnd);
  209.             for (x=0;x<=cur_round;x++)
  210.             {
  211.                 for (y=0;y<4;y++)
  212.                     vPutPeg(hWnd,board[x][y],x,y);
  213.                 vDoClues(hWnd,x);
  214.             }
  215.             if (winstate == 1)
  216.                 vDoWin(hWnd);
  217.             else
  218.                 if (winstate == 2)
  219.                     vDoLoose(hWnd);
  220.  
  221.             break;
  222.  
  223.  
  224.         case WM_COMMAND:         /* message: command from application menu */
  225.             switch(wParam)
  226.             {
  227.                 case DIDIGETITRIGHT:
  228.                     if (!winstate)    /* If won or lost ignore commands */
  229.                     {
  230.                         if (!bCheckfill()) break;
  231.                         if (bCheckguess(cur_round))
  232.                         {
  233.                             vDoWin(hWnd);
  234.                             break;
  235.                         }
  236.                         else
  237.                         {
  238.                             vDoClues(hWnd,cur_round);
  239.                             cur_round++;
  240.                             if (cur_round == 10) /* You loose */
  241.                                 vDoLoose(hWnd);
  242.                         }
  243.                     }
  244.                     break;
  245.  
  246.                 case IDM_ABOUT:
  247.                     lpProcAbout = MakeProcInstance(About, hInst);
  248.  
  249.                     DialogBox(hInst,            /* current instance */
  250.                                  "AboutBox",   /* resource to use */
  251.                                  hWnd,            /* parent handle */
  252.                                  lpProcAbout);    /* About() instance address */
  253.  
  254.                     FreeProcInstance(lpProcAbout);
  255.                     break;
  256.  
  257.                 case IDM_NEW:  /* Let's play again */
  258.                   InvalidateRect(hWnd, NULL, TRUE);
  259.                   SendMessage(hWnd,WM_CREATE,NULL,NULL);
  260.                   break;
  261.  
  262.                 case IDM_GIVEUP:
  263.                     vDoLoose(hWnd);
  264.                     break;
  265.  
  266.                 case IDM_HELP:
  267.                     lpProcAbout = MakeProcInstance(About, hInst);
  268.  
  269.                     DialogBox(hInst,            /* current instance */
  270.                                  "HelpBox",   /* resource to use */
  271.                                  hWnd,            /* parent handle */
  272.                                  lpProcAbout);    /* About() instance address */
  273.  
  274.                     FreeProcInstance(lpProcAbout);
  275.                     break;
  276.  
  277.                 default:               /* Lets Windows process it */
  278.                     return (DefWindowProc(hWnd, message, wParam, lParam));
  279.             }
  280.             break;
  281.  
  282.         case WM_DESTROY:            /* message: window being destroyed */
  283.             DeleteObject(hBoardmap);
  284.             DeleteObject(hPegBoardmap);
  285.             DeleteObject(hBlclpegmap);
  286.             DeleteObject(hWhclpegmap);
  287.             for (x=0;x<8;x++)
  288.                 DeleteObject(hPegs[x]);
  289.             PostQuitMessage(0);
  290.             break;
  291.  
  292.         default:                /* Passes it on if unprocessed */
  293.             return (DefWindowProc(hWnd, message, wParam, lParam));
  294.     }
  295.     return (NULL);
  296. }
  297.  
  298. /*********************************************************************/
  299.  
  300. BOOL FAR PASCAL About(hDlg, message, wParam, lParam)
  301. HWND hDlg;                       /* window handle of the dialog box */
  302. unsigned message;                /* type of message */
  303. WORD wParam;                    /* message-specific information */
  304. LONG lParam;
  305. {
  306.     switch (message)
  307.     {
  308.         case WM_INITDIALOG:              /* message: initialize dialog box */
  309.             return (TRUE);
  310.  
  311.         case WM_COMMAND:                  /* message: received a command */
  312.             if (wParam == IDOK ||        /* "OK" box selected ? */
  313.               wParam == IDCANCEL)       /* System menu close command ? */
  314.             {
  315.                 EndDialog(hDlg, TRUE);    /* Exits the dialog box */
  316.                 return (TRUE);
  317.             }
  318.             break;
  319.     }
  320.     return (FALSE);
  321. }
  322.  
  323. /*****************/
  324. /* Clear the board and the clues for a new game */
  325. void vInitialize(void)
  326. {
  327.     int x,y;
  328.  
  329.     for(x=0;x<=9;x++)
  330.         for(y=0;y<=3;y++)
  331.         {
  332.             board[x][y] = -1;
  333.             clues[x][y] = ' ';
  334.         }
  335.     cur_round = 0;
  336.     winstate = 0;
  337.     return;
  338. }
  339.  
  340. /*****************/
  341. /* Scramble the position of clues */
  342. void vScrambleclues(int round)
  343. {
  344.     int x,y=0,signal=1;
  345.     char tempclues[4]={'\0','\0','\0','\0'};
  346.  
  347.     while (signal)
  348.     {
  349.         x=(rand() % 4);
  350.         if (tempclues[x]=='\0')
  351.         {
  352.             tempclues[x] = clues[round][y];
  353.             y++;
  354.             if (y>3) signal = 0;
  355.         }
  356.     }
  357.     for(x=0;x <=3;x++)
  358.         clues[round][x]=tempclues[x];
  359.     return;
  360. }
  361.  
  362. /*****************/
  363. /* Check the guess for clues or win */
  364. BOOL bCheckguess(int round)
  365. {
  366.     int x,y=0;
  367.     int tempcode[4], temp[4];
  368.  
  369.     for(x=0;x<=3;x++)                   /* prepare temporary arrays */
  370.     {
  371.         temp[x]=board[round][x];
  372.         tempcode[x]=code[x];
  373.         clues[round][x] = ' ';
  374.     }
  375.  
  376.     for(x=0;x<=3;x++)                            /* check for perfect match */
  377.         if (temp[x] == tempcode[x])
  378.         {
  379.             clues[round][x]='1';
  380.             temp[x]=-2;
  381.             tempcode[x]=-1;
  382.             y++;
  383.         }
  384.  
  385.     if (y==4) return(TRUE);
  386.  
  387.     for(x=0;x<=3;x++)                            /* check for right colour */
  388.         for(y=0;y<=3;y++)                        /*   wrong position       */
  389.         {
  390.             if (tempcode[x]==temp[y])
  391.             {
  392.                 clues[round][y] = '0';
  393.                 temp[y] = -2;
  394.                 tempcode[x] = -1;
  395.                 break;
  396.             }
  397.         }
  398.     vScrambleclues(round);
  399.     return(FALSE);
  400. }
  401.  
  402. /*****************/
  403. /* Make sure all the buttons were clicked */
  404. BOOL bCheckfill(void)
  405. {
  406.     int x;
  407.  
  408.     for(x=0;x<=3;x++)
  409.         if (board[cur_round][x] == -1)
  410.             return(FALSE);
  411.     return(TRUE);
  412. }
  413.  
  414. /*****************/
  415. /* Generate the secret code */
  416. void vMakecode(void)
  417. {
  418.     int x;
  419.     time_t t;
  420.  
  421.     srand((unsigned) time(&t));
  422.  
  423.     for(x=0;x<=3;x++)
  424.         code[x]= (rand() % 8);
  425.  
  426.     return;
  427. }
  428.  
  429. /***********************/
  430. /* Create the buttons on screen */
  431. BOOL bMakeGameButtons(HWND hWnd)
  432. {
  433.  
  434.     if (DidIGetItRight != NULL) DestroyWindow(DidIGetItRight);
  435.     DidIGetItRight = CreateWindow("Button",
  436.                                             "Did I Get It Right?",
  437.                                             BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE,
  438.                                             10, 350, 168, 20,
  439.                                             hWnd,
  440.                                             DIDIGETITRIGHT,
  441.                                             hInst,
  442.                                             NULL);
  443.     if (!DidIGetItRight)
  444.         return(FALSE);
  445.     ShowWindow(DidIGetItRight, SW_SHOW);
  446.     UpdateWindow(DidIGetItRight);
  447.     return(TRUE);
  448. }
  449.  
  450. /*******************************/
  451. /* The basic game board setup  */
  452. /*******************************/
  453. void vBasicScreen(HWND hWnd)
  454. {
  455.     HDC hDC,hMemoryDC;
  456.     PAINTSTRUCT ps;
  457.     int x,y;
  458.  
  459.     hDC = BeginPaint(hWnd, &ps);
  460.     hMemoryDC = CreateCompatibleDC(hDC);
  461.  
  462.     hOldBitmap = SelectObject(hMemoryDC,hBoardmap);        /* Game board */
  463.     GetObject(hBoardmap, sizeof(BITMAP), (LPSTR) &Bitmap);
  464.     BitBlt(hDC,10,10,Bitmap.bmWidth, Bitmap.bmHeight,
  465.              hMemoryDC,0,0,SRCCOPY);
  466.  
  467.     hOldBitmap = SelectObject(hMemoryDC,hPegBoardmap);     /* Peg board  */
  468.     GetObject(hPegBoardmap, sizeof(BITMAP), (LPSTR) &Bitmap);
  469.     BitBlt(hDC,190,154,Bitmap.bmWidth, Bitmap.bmHeight,
  470.              hMemoryDC,0,0,SRCCOPY);
  471.  
  472.     y = 158;
  473.     for (x=0;x<8;x++)                                      /* Pegs       */
  474.     {
  475.         hOldBitmap=SelectObject(hMemoryDC,hPegs[x]);
  476.         GetObject(hPegs[x], sizeof(BITMAP), (LPSTR) &Bitmap);
  477.         BitBlt(hDC,194,y,Bitmap.bmWidth, Bitmap.bmHeight,
  478.                  hMemoryDC,0,0,SRCCOPY);
  479.         y += 23;
  480.     }
  481.  
  482.     SelectObject(hMemoryDC, hOldBitmap);
  483.     DeleteDC(hMemoryDC);
  484.     ReleaseDC(hWnd, hDC);
  485.     EndPaint(hWnd, &ps);
  486.  
  487.     return;
  488. }
  489.  
  490. /***************************************/
  491. /* Check where mouse was clicked and   */
  492. /* decide if a peg was selected or a   */
  493. /* position on the board was selected. */
  494. /***************************************/
  495. BOOL bCheckPosition(HWND hWnd)
  496. {
  497.     int x,y,z,row=-1;
  498.     BOOL recX = FALSE;
  499.     BOOL recY = FALSE;
  500.  
  501.     if ((iYpos<=344-(cur_round*30)) && (iYpos>=314-(cur_round*30)))
  502.     {
  503.         recY = TRUE;
  504.         z = 0;
  505.         for(x=16;x<=118;x+=27)
  506.         {
  507.             if ((iXpos>=x) && (iXpos<=(x+27)))
  508.             {
  509.                 recX = TRUE;
  510.                 break;
  511.             }
  512.             z++;
  513.         }
  514.     }
  515.     if ((recX) && (recY))
  516.     {
  517.         cur_column = z;
  518.         return(TRUE);
  519.     }
  520.     else
  521.     {
  522.         for(y=0;y<=7;y++)
  523.         {
  524.             if ((iYpos>=(y*23+158)) && (iYpos<=(y*23+181)))
  525.             {
  526.                 row = y;
  527.                 break;
  528.             }
  529.         }
  530.         if ((row > -1) && ((iXpos>=194) && (iXpos<=218)))
  531.         {
  532.             curcolour = row;
  533.             vMarkColour(hWnd);
  534.         }
  535.     }
  536.  
  537.     return(FALSE);
  538. }
  539. /********************************/
  540. /* Place the selected peg at the*/
  541. /* appropriate position         */
  542. /********************************/
  543. void vPutPeg(HWND hWnd, int colour, int round, int column)
  544. {
  545.     HDC hDC,hMemoryDC;
  546.  
  547.     if (board[round][column] == -1) return;
  548.     hDC = GetDC(hWnd);
  549.     hMemoryDC = CreateCompatibleDC(hDC);
  550.     hOldBitmap = SelectObject(hMemoryDC,hPegs[colour]);
  551.     GetObject(hPegs[colour], sizeof(BITMAP), (LPSTR) &Bitmap);
  552.     BitBlt(hDC,column*27+16,314-round*30,Bitmap.bmWidth, Bitmap.bmHeight,
  553.              hMemoryDC,0,0,SRCCOPY);
  554.  
  555.     DeleteDC(hMemoryDC);
  556.     ReleaseDC(hWnd, hDC);
  557.  
  558.     return;
  559. }
  560.  
  561. /**************************/
  562. /* Display the secret code*/
  563. /**************************/
  564. void vShowCode(HWND hWnd)
  565. {
  566.     int x;
  567.     HDC hDC,hMemoryDC;
  568.  
  569.     hDC = GetDC(hWnd);
  570.     hMemoryDC = CreateCompatibleDC(hDC);
  571.     for (x=0;x<4;x++)
  572.     {
  573.         hOldBitmap = SelectObject(hMemoryDC,hPegs[code[x]]);
  574.         GetObject(hPegs[code[x]], sizeof(BITMAP), (LPSTR) &Bitmap);
  575.         BitBlt(hDC,x*27+16,15,Bitmap.bmWidth, Bitmap.bmHeight,
  576.                  hMemoryDC,0,0,SRCCOPY);
  577.     }
  578.  
  579.     DeleteDC(hMemoryDC);
  580.     ReleaseDC(hWnd, hDC);
  581.     return;
  582. }
  583.  
  584. /***************************/
  585. /* Winner's routine        */
  586. /***************************/
  587. void vDoWin(HWND hWnd)
  588. {
  589.     HDC         hDC;
  590.  
  591.     vShowCode(hWnd);
  592.  
  593.     hDC = GetDC(hWnd);
  594.     SetTextColor(hDC,RGB(0,255,0));
  595.     SetBkMode(hDC,TRANSPARENT);
  596.     strcpy(str,"WIN!");
  597.     TextOut(hDC,130,18,str,strlen(str));
  598.     ReleaseDC(hWnd, hDC);
  599.     winstate = 1;
  600.     return;
  601. }
  602.  
  603. /***************************/
  604. /* Looser's routine        */
  605. /***************************/
  606. void vDoLoose(HWND hWnd)
  607. {
  608.     HDC         hDC;
  609.  
  610.     vShowCode(hWnd);
  611.  
  612.     hDC = GetDC(hWnd);
  613.     SetTextColor(hDC,RGB(255,0,0));
  614.     SetBkMode(hDC,TRANSPARENT);
  615.     strcpy(str,"LOOSE!");
  616.     TextOut(hDC,125,18,str,strlen(str));
  617.     ReleaseDC(hWnd, hDC);
  618.     winstate = 2;
  619.  
  620.     return;
  621. }
  622. /*************************/
  623. /* Display the clue pegs */
  624. /*************************/
  625. void vDoClues(HWND hWnd, int round)
  626. {
  627.     int x,y=0;
  628.     HDC hDC,hMemoryDC;
  629.     hDC = GetDC(hWnd);
  630.     hMemoryDC = CreateCompatibleDC(hDC);
  631.     for (x=0;x<4;x++)
  632.     {
  633.         if (clues[round][x] == '1')
  634.         {
  635.             hOldBitmap = SelectObject(hMemoryDC,hWhclpegmap);
  636.             GetObject(hWhclpegmap, sizeof(BITMAP), (LPSTR) &Bitmap);
  637.             BitBlt(hDC,y*12+125,320-(round*30),Bitmap.bmWidth, Bitmap.bmHeight,
  638.                      hMemoryDC,0,0,SRCCOPY);
  639.             y++;
  640.         }
  641.         else
  642.             if (clues[round][x] =='0')
  643.             {
  644.                 hOldBitmap = SelectObject(hMemoryDC,hBlclpegmap);
  645.                 GetObject(hBlclpegmap, sizeof(BITMAP), (LPSTR) &Bitmap);
  646.                 BitBlt(hDC,y*12+125,320-(round*30),Bitmap.bmWidth, Bitmap.bmHeight,
  647.                          hMemoryDC,0,0,SRCCOPY);
  648.                 y++;
  649.             }
  650.     }
  651.  
  652.     DeleteDC(hMemoryDC);
  653.     ReleaseDC(hWnd, hDC);
  654.     return;
  655. }
  656.  
  657. /*******************************/
  658. /* Mark the selected colour    */
  659. /*******************************/
  660. void vMarkColour(HWND hWnd)
  661. {
  662.     HDC         hDC;
  663.  
  664.     hDC = GetDC(hWnd);
  665.     if (prevcolour != -1)
  666.     {
  667.         SetTextColor(hDC,GetBkColor(hDC));
  668.         SetBkMode(hDC,TRANSPARENT);
  669.         strcpy(str,"*");
  670.         TextOut(hDC,220,prevcolour*23+165,str,strlen(str));
  671.     }
  672.     SetTextColor(hDC,RGB(0,0,0));
  673.     SetBkMode(hDC,TRANSPARENT);
  674.     strcpy(str,"*");
  675.     TextOut(hDC,220,curcolour*23+165,str,strlen(str));
  676.     prevcolour = curcolour;
  677.  
  678.     ReleaseDC(hWnd, hDC);
  679.     return;
  680. }
  681.